package com.hqbzl.c1.cass;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;

// 累加器
@Slf4j
public class Test41 {
    public static void main(String[] args) {
        // 1。8提供，效率高
        final LongAdder longAdder = new LongAdder();
        longAdder.increment();

        final AtomicLong atomicLong = new AtomicLong(0);
        final long andIncrement = atomicLong.incrementAndGet();
        System.out.println("longAdder.longValue() = " + longAdder.longValue());
        System.out.println("andIncrement = " + andIncrement);
    }
}
